<template>
  <div class="login-main">
    <div class="login-form">
      <h2>喵喵喵后台管理注册</h2>
      <el-form label-width="80px" class="form" :model="searchForm">
        <el-form-item label="用户名" prop="username">
          <el-input v-model="username" size="large"></el-input>
        </el-form-item>
        <el-form-item label="密码" prop="password">
          <el-input v-model="password" type="password" size="large"></el-input>
        </el-form-item>
        <el-form-item label="姓名" prop="name">
          <el-input v-model="name" size="large"></el-input>
        </el-form-item>
        <el-form-item label="手机号" prop="contactNumber">
          <el-input v-model="contactNumber" size="large"></el-input>
        </el-form-item>
        <el-form-item label="学号" prop="studentId">
          <el-input v-model="studentId" size="large"></el-input>
        </el-form-item>
        <div class="login-btn">
          <el-button @click="userSign">注册</el-button>
          <el-button @click="userLogin">返回</el-button>
        </div>
      </el-form>
    </div>
  </div>
</template>

<script setup lang="ts">
import { handleErrorMessage } from '@/api/utils/handleErrorMessage'
import { registrationApi } from '../../api/component/users/login'
import { reactive, toRefs } from 'vue'
import type { SignParams } from '@/api/types/sign'

const searchForm = reactive({
  username: '',
  password: '',
  name: '',
  contactNumber: '',
  studentId: ''
}) as SignParams
const userSign = async () => {
  try {
    await registrationApi({ ...searchForm })
  } catch (error) {
    handleErrorMessage(error, '注册失败，请检查输入是否正确')
  }
}
const userLogin = () => {}
const { username, password, name, contactNumber, studentId } = toRefs(searchForm)
</script>
<style lang="scss" scoped>
.login-main {
  position: relative;
  height: 100%;
  width: 100%;
  background: url(../../assets/img/img1.jpg);
  background-size: 100% 100%;
  background-repeat: no-repeat;
  .login-form {
    position: relative;
    left: 50%;
    top: 20%;
    transform: translate(-50%);
    width: 400px;
    height: 430px;
    background: rgba(224, 170, 212, 0.6);
    border-radius: 10px;
    padding: 16px;
    box-sizing: border-box;
    h2 {
      text-align: center;
    }
    .form {
      position: relative;
      top: 30px;
    }
    .login-btn {
      width: 100%;
      text-align: center;
    }
  }
}
</style>
